home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QRZ! Ham Radio 8
/
QRZ Ham Radio Callsign Database - Volume 8.iso
/
mac
/
files
/
t_nansi
/
nan24hyc.arc
/
nansi.doc
< prev
next >
Wrap
Text File
|
1990-10-31
|
12KB
|
274 lines
nansi - Enhanced MS-DOS ansi console driver
SYNOPSIS
Include in \config.sys the line
device=nansi.sys
DESCRIPTION
Nansi.sys is a console driver which understands ANSI control sequences.
It has several advantages over ANSI.SYS (the driver supplied with DOS):
1. It supports new escape sequences (see below).
2. It provides MUCH faster output under certain conditions.
3. It supports EGA 43-line mode and ATT 6300 50-line mode.
4. The darned bell is now 1/4 second instead of 1/2 second long.
What a console driver does:
When you, for example, type
C:> type foo.txt
COMMAND.COM opens the file foo.txt, reads it, and writes it to
the console driver, which puts it up on the screen.
Both ansi.sys and nansi.sys use IBM Video BIOS to control the screen.
However, nansi.sys bypasses BIOS if the screen is in a text mode; this
allows much faster operation under certain conditions.
While putting text up on the screen, (n)ansi.sys keeps a lookout for
the escape character (chr(27), known as ESC); this character signals
the start of a terminal control sequence.
Terminal control sequences follow the format
ESC [ param; param; ...; param cmd
where
ESC is the escape character chr$(27).
[ is the left bracket character.
param is an ASCII decimal number, or a string in quotes.
cmd is a case-specific letter identifying the command.
Usually, zero, one, or two parameters are given. If parameters
are omitted, they usually default to 1; however, some commands
(KKR and DKOCT) treat the no-parameter case specially.
Spaces are not allowed between parameters.
For example, both ESC[1;1H and ESC[H send the cursor to the home
position (1,1), which is the upper left.
Either single or double quotes may be used to quote a string.
Each character inside a quoted string is equivalent to one numeric
parameter. Quoted strings are normally used only for the Keyboard
Key Reassignment command.
Control Sequences
The following table lists the sequences understood by nansi.sys.
Differences between nansi.sys and the standard ansi.sys are marked
with a vertical bar (|).
Cursor Positioning
Short Long name Format Notes
CUP cursor position ESC[y;xH Sets cursor position.
HVP cursor position ESC[y;xf Same as CUP; not recommended.
CUU cursor up ESC[nA n = # of lines to move
CUD cursor down ESC[nB
CUF cursor forward ESC[nC n = # of columns to move
CUB cursor backward ESC[nD
DSR Device Status, Report! ESC[6n Find out cursor position.
CPR Cursor Position report ESC[y;xR<CR> Response to DSR, as if typed.
SCP Save Cursor Position ESC[s Not nestable.
RCP Restore Cursor Position ESC[u
Editing
ED | Erase in Display ESC[0J or ESC[J Clear to end of screen.
| ESC[1J Clear to start of screen.
ESC[2J Clears screen.
EL Erase in Line ESC[K Clears to end of line.
IL | Insert Lines ESC[nL Inserts n blank lines at cursor line.
DL | Delete Lines ESC[nM Deletes n lines, including cursor line.
ICH | Insert Characters ESC[n@ Inserts n blank chars at cursor.
DCH | Delete Characters ESC[nP Deletes n chars, including cursor char.
Mode-Setting
SGR Set Graphics Rendition ESC[n;n;...nm See character attribute table.
SM Set Mode ESC[=nh See screen mode table.
RM Reset Mode ESC[=nl See screen mode table.
IBMKKR Keyboard Key Reass. ESC["string"p
The first char of the string gives the key to redefine; the rest
of the string is the key's new value.
To specify unprintable chars, give the ASCII value of the char
outside of quotes, as a normal parameter.
IBM function keys are two byte strings; see the IBM Basic manual.
For instance, ESC[0;";dir a:";13;p redefines function key 1 to
have the value "dir a:" followed by the ENTER key.
| If no parameters given, all keys are reset to their default values.
DKOCT | Output char translate ESC[n;ny
| When first char is encountered in output request, it is replaced with
| the second char. This might be useful for previewing text before
| sending it to a printer with a funny print wheel.
| If no parameters are given, all chars are reset to normal.
Character Attributes
The Set Graphics Rendition command is used to select foreground
and background colors or attributes.
When you use multiple parameters, they are executed in sequence, and
the effects are cumulative.
Attrib code Value
0 All attributes off (normal white on black)
1 Bold
4 Underline
5 Blink
7 Reverse Video
8 Invisible (but why?)
30-37 foregnd blk/red/grn/yel/blu/magenta/cyan/white
40-47 background (no effect in graphics modes)
Screen Modes
The Set Mode and Reset Mode sequences both accept one parameter,
with the following values:
Mode Code Value (same for Set and for Reset)
0 text 40x25 Black & White
1 text 40x25 Color
2 text 80x25 Black & White
3 text 80x25 Color
4 bitmap 320x200 4 bits/pixel
5 bitmap 320x200 1 bit/pixel
6 bitmap 640x200 1 bit/pixel
| 13 EGA graphics 320x200 4 bits/pixel
| 14 EGA graphics 640x200 4 bits/pixel
| 15 EGA [ IBM Monochrome display 640x350 2 bits/pixel?]
| 16 EGA graphics 640x350 4 bits/pixel [with full 256K]
Mode Code Set Reset
7 *Wrap at end of line No wrap at EOL
| 43 43 Lines on EGA *25 Lines
| 44 Wait for retrace *No wait
| 45 *Graphics Cursor No simulated graphics cursor
| 50 50 Lines on ATT 6300 *25 Lines
[ * = default ]
Screen Snow
If your screen flares up with annoying little white bars ("snow"),
you probably should tell Nansi to wait for retrace before writing
to the screen, by sending the string
ESC [ = 44 h
This doesn't clear up the snow under all conditions, but it helps
quite a bit. Unfortunately, it also slows down output somewhat.
Little Dead Blobs
If you are using a graphics mode, and the cursor leaves little
dead blobs behind when it moves, you are probably using a program
which bypasses DOS (naughty, naughty). It might help to tell
Nansi to turn off its graphics cursor by sending the string
ESC [ = 45 l
(The last character in that string is a lowercase "L".)
Faster Output
Any program that
1) uses Nansi.sys,
2) sets the console to RAW mode (with IOCTL), and
3) buffers its output (C programmers: use setbuf),
can achieve EXTREMELY high screen update speeds in return
for giving up the special functions of the keys ^C, ^S, and ^P
(which many programs, editors for example, don't want anyway).
See IOCTL in the MS-DOS 3.x Technical Reference for more info.
Portability to Microsoft Windows
According to Microsoft, any program that uses ANSI.SYS escape
sequences will work under Microsoft Windows without changes.
It appears that the speed advantages of Nansi may be preserved
by MS-Windows when better graphics boards become available.
This is one of the best reasons for using Nansi instead of
directly accessing the memory mapped video text buffer.
[ Caveat: I have found that Cursor Position Report simply
does not work under MS-Windows. This is a shame, because
CPR makes it possible for text editors to automatically sense
the size of the screen. ]
EXAMPLES
See the files setraw.* for Macro Assembler, Lattice C,
and Microsoft C routines for entering and leaving raw mode.
The files mode*.txt included with nansi.sys in the library
new_ansi.lbr contain the Set Mode sequences to set various
screen modes; for instance, to try out 43 line mode, type
C:> type MODE43.TXT
[ To get back to normality, type the file "mode3.txt"; don't use
the mode command, as that doesn't let nansi know what happened...]
The programs view.com and more.com are demos of this driver's
blinding screen update speed; refer to view.doc and more.doc for
details. Briefly, typing
C:> more foo.txt
shows you the file foo.txt, pausing every 24 lines for you to hit
the spacebar. Typing
C:> view foo.txt
shows you the first page of the file foo.txt; typing PgUp or PgDn moves
you backwards or forwards in the file; typing 'q' exits to DOS.
BUGS
The Set Mode and Reset Mode codes 43, 44, 45, and 50 were chosen
without even looking to see if there are established codes
for those functions.
Insert and delete character do not work in graphics modes
because BIOS does not include a scroll left/right function.
Graphics mode writing is slow because it uses BIOS.
It is difficult to add new screen access methods to nansi.asm;
nansi should be rewritten so parsing text into printable
blocks is separate from writing those blocks onto the screen.
Does not support some other useful functions.
Cursor Position Report has a carriage return in it, which is what
ansi.sys does, but is nonstandard.
When using 43 line mode, typing MODE CO80 will get you back
to 25 line mode- but NANSI will still scroll as if there were 43
lines! You have to use the SET MODE escape sequence instead of MODE.
Should either intercept BIOS calls or sense the extended AT/EGA bios
variable for # of lines.
Version
This is a modification of NANSI 2.4, incorporating changes made
by Ron Henderson <crh@hpcvmcrh.cv.hp.com> to version 2.2. These
changes (non-destructive tab, ignore NULLs instead of outputing
as spaces, send "nansi" in response to ESC[c query, clear with
ESC [ J, ESC [ 0 J, ESC [ 1 J) were merged into NANSI 2.4 by
Howard Chu <hyc@admin.lsa.umich.edu>, Oct. 30, 1990. This doc
file has been updated to represent the current state.
(The version number can be found by typing TYPE NANSI.SYS.)
This version, 2.4, created August 1986.
It fixes several nasty bugs in the last release (2.2), so please
pass this version on to anyone who had the old version.
NOTE
I intend to upgrade this program from time to time, and will
post new versions to Usenet.
Problems or suggestions should be sent to the author, Daniel Kegel:
Post: 17 Mulberry Street
Rochester, NY 14620 USA
Usenet: ...rochester!srs!dan
My thanks to Ed Nather, Pete Galvin, Bill Dudley, and others
who have helped fix bugs or who have contributed features.
This program and all files associated with it are hereby placed
in the public domain, and thus may be freely copied and distributed.
If you really like this program, either
(a) improve it, and place your improvements in the public domain,
(b) write a neat program which uses Nansi's unique speed, and
place your program in the public domain,
(c) tip the author (Tip; contraction for "To Inspire Programmer";
traditionally, a contribution of $5 per copy), or
(d) resolve to become a better human being in the future.
However, I suggest that any modifications be clearly marked, and
(if reasonable) surrounded by IF/ ELSE/ ENDIF statements.
The programmer doing the modification should append his/her initials
to the version number string (near the device driver header).
FILES
makefile
nansi*.asm - console driver source files
nansi.sys - console driver executable file
nansi.doc - console driver documentation (this file)
view.* - a fast VI-like file viewer, documentation
more.* - a fast page-at-a-time TYPE command, documentation
unsetraw.* - program to set/unset RAW mode from DOS command line
mode*.set - example Set Mode escape sequences
mode*.rst - example Reset Mode escape sequences